<template>
  <el-config-provider :locale="currentLocale">
    <router-view />
    <ReDialog />
  </el-config-provider>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { checkVersion } from "version-rocket";
import { ElConfigProvider } from "element-plus";
import en from "element-plus/dist/locale/en.mjs";
import { ReDialog } from "@/components/ReDialog";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import { useAppStoreHook } from "@/store/modules/app";
export default defineComponent({
  name: "app",
  components: {
    [ElConfigProvider.name]: ElConfigProvider,
    ReDialog
  },
  computed: {
    currentLocale() {
      return this.$storage.locale?.locale === "zh" ? zhCn : en;
    }
  },
  beforeCreate() {
    useAppStoreHook().setScreenSize(window.screen.width, window.screen.height);
    // socket连接 消息统一pinna
    const { version, name: title } = __APP_INFO__.pkg;
    const { VITE_PUBLIC_PATH, MODE } = import.meta.env;
    // https://github.com/guMcrey/version-rocket/blob/main/README.zh-CN.md#api
    if (MODE === "production") {
      // 版本实时更新检测，只作用于线上环境
      checkVersion(
        // config
        {
          // 5分钟检测一次版本
          pollingTime: 300000,
          localPackageVersion: version,
          originVersionFileUrl: `${location.origin}${VITE_PUBLIC_PATH}version.json`
        },
        // options
        {
          title,
          description: "检测到新版本",
          buttonText: "立即更新"
        }
      );
    }
  }
});
</script>

<style lang="scss">
@font-face {
  font-family: douyuzhuiguangti;
  font-style: normal;
  font-weight: normal;
  src: url("@/views/DataV/first/assets/font/douyuzhuiguangti.ttf")
    format("truetype");
  font-display: swap;
}

.columns-show-group {
  margin-top: 6px;

  .el-checkbox {
    display: block;
  }
}

.my-notice {
  width: 380px !important;
}

.public-disabled-label .el-form-item__label {
  color: #a8abb2;
  cursor: no-drop;
}
</style>
